package psi

import (
	"fmt"
	"strings"
)

/*
设置拨号盘开关
平台发送：
[DW*YYYYYYYYYYYYYYY*LEN*KEYBRD, 开关（0 关，1 开）]
拨号盘默认初始值为开
例:[DW*334588000000156*0008*KEYBRD,0]
[DW*334588000000156*LEN*KEYBRD,0]
终端回复:
[DW*YYYYYYYYYYYYYYY*LEN*KEYBRD]
实例:[DW*334588000000156*0006*KEYBRD]
*/

// 设置拨号盘开关
type KEYBRD struct {
	Switch int // 开关（0 关，1 开）
}

func DealKEYBRD(method string, params map[string]interface{}) (string, error) {
	var keybrd KEYBRD
	err := MapToStruct(params, &keybrd)
	if err != nil {
		return "", err
	}
	var messageList []string
	messageList = append(messageList, "KEYBRD")
	messageList = append(messageList, fmt.Sprint(keybrd.Switch))
	message := strings.Join(messageList, ",")
	return message, nil
}
